package com.neusoft.reflect;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author: duan
 * @Date: Create in 19:04 2020/10/12
 */
public class Demo {
    public static void main(String[] args) {
        Pattern pattern = Pattern.compile("[A-Z]");
        Matcher matcher = pattern.matcher("marginTopHello");
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
        }
        matcher.appendTail(sb);
        System.out.println(sb.toString());
    }
}
